package com.coda.controller;

import com.coda.adminVo.appointment.AppointmentQueryVo;
import com.coda.result.PageResult;
import com.coda.result.Result;
import com.coda.service.ViewAppointmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/appointment")
@Api(tags = "看房预约管理")
public class ViewAppointmentController {

    @Autowired
    private ViewAppointmentService viewAppointmentService;
    /**
     * 条件分页查询租约信息
     */
    @GetMapping("/page")
    @ApiOperation("条件分页查询租约信息")
    public Result<PageResult> getPageList(@RequestParam Integer current,
                                          @RequestParam Integer size,
                                          AppointmentQueryVo appointmentQueryVo){
        PageResult pageResult = viewAppointmentService.getPageList(current, size, appointmentQueryVo);
        return Result.ok(pageResult);
    }
    /**
     * 根据id更新预约状态
     */
    @PostMapping("/updateStatusById")
    @ApiOperation("根据id更新预约状态")
    public Result updateStatusById(@RequestParam Long id, @RequestParam Integer status){
        viewAppointmentService.updateStatusById(id,status);
        return Result.ok();
    }


}
